package com.itheima.aop;

import com.mysql.cj.callback.MysqlCallbackHandler;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class RecordTimeApsect2 {
    @Pointcut("@annotation(com.itheima.aop.Log)")  // 注释的全限定名
    public void pt(){}

    @Around("pt()")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("RecordTimeApsect2-recordTime-记录时间");
        long start = System.currentTimeMillis();

        Object result = pjp.proceed();

        long end = System.currentTimeMillis();

        System.out.println("RecordTimeApsect2-recordTime- 方法执行时间：" + (end-start));

        return result;
    }
}
